<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录与找回密码</title>
    <link rel="stylesheet" href="css/style.css">
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .container {
            background-color: white;
            padding: 20px;
            border-radius: 12px;
            box-shadow: 0 6px 16px rgba(0,0,0,0.08);
            width: 400px;
        }
        .tab {
            overflow: hidden;
            border: 1px solid #E1E5EB;
            background-color: var(--light);
        }
        .tab button {
            background-color: inherit;
            float: left;
            border: none;
            outline: none;
            cursor: pointer;
            padding: 14px 16px;
            transition: 0.3s;
        }
        .tab button:hover {
            background-color: #ddd;
        }
        .tab button.active {
            background-color: #ccc;
        }
        .tabcontent {
            display: none;
            padding: 6px 12px;
            border: 1px solid #ccc;
            border-top: none;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        input[type="text"], input[type="email"], input[type="password"], input[type="tel"] {
            width: 100%;
            padding: 8px;
            box-sizing: border-box;
        }
        button[type="submit"] {
            background-color: #4CAF50;
            color: white;
            padding: 10px 15px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        button[type="submit"]:hover {
            background-color: #45a049;
        }
        .verification-code {
            display: flex;
            gap: 10px;
        }
        .verification-code input {
            flex: 1;
        }
        .verification-code button {
            padding: 8px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="tab">
            <button class="tablinks" onclick="openTab(event, 'login')">登录</button>
            <button class="tablinks" onclick="openTab(event, 'forgotPassword')">找回密码</button>
        </div>

        <div id="login" class="tabcontent">
            <form id="loginForm">
                <div class="form-group">
                    <label for="loginAccount">账号（邮箱/手机号）</label>
                    <input type="text" id="loginAccount" required>
                </div>
                <div class="form-group">
                    <label for="loginPassword">密码</label>
                    <input type="password" id="loginPassword" required>
                </div>
                <button type="submit">登录</button>
            </form>
        </div>

        <div id="forgotPassword" class="tabcontent">
            <form id="forgotPasswordForm">
                <div class="form-group">
                    <label for="forgotAccount">账号（邮箱/手机号）</label>
                    <input type="text" id="forgotAccount" required>
                </div>
                <div class="form-group verification-code">
                    <input type="text" id="forgotVerificationCode" placeholder="验证码">
                    <button type="button" onclick="sendVerificationCode('forgotAccount')">获取验证码</button>
                </div>
                <div class="form-group">
                    <label for="newPassword">新密码</label>
                    <input type="password" id="newPassword" required>
                </div>
                <button type="submit">重置密码</button>
            </form>
        </div>
    </div>

    <script>
        function openTab(evt, tabName) {
            var i, tabcontent, tablinks;
            tabcontent = document.getElementsByClassName("tabcontent");
            for (i = 0; i < tabcontent.length; i++) {
                tabcontent[i].style.display = "none";
            }
            tablinks = document.getElementsByClassName("tablinks");
            for (i = 0; i < tablinks.length; i++) {
                tablinks[i].className = tablinks[i].className.replace(" active", "");
            }
            document.getElementById(tabName).style.display = "block";
            evt.currentTarget.className += " active";
        }

        function sendVerificationCode(fieldId) {
            const field = document.getElementById(fieldId);
            if (field.value) {
                // 实际开发中需要实现发送验证码的逻辑
                alert(`验证码已发送至 ${field.value}`);
            } else {
                alert('请先填写邮箱或手机号');
            }
        }

        document.getElementById('loginForm').addEventListener('submit', function(e) {
            e.preventDefault();
            // 实际开发中需要实现登录逻辑
            alert('登录成功');
        });

        document.getElementById('forgotPasswordForm').addEventListener('submit', function(e) {
            e.preventDefault();
            // 实际开发中需要实现找回密码逻辑
            alert('密码重置成功');
        });
    </script>
</body>
</html>